package collection;

import day07.BuyChickens;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorDemo {
    public static void main(String[] args) {
        Collection<Object> c=new ArrayList();
        c.add("one");
        c.add("#");
        c.add("two");
        c.add("#");
      //  Iterable
        ((ArrayList)c).set(1,null);
        Iterator<Object> it=c.iterator();
        while (it.hasNext()){
           // c.remove("two");
            String str=(String) it.next();
            System.out.print(str+"\t");
            if(str==null)
                continue;
            if(str.equals("#")){
                it.remove();
            }
        }
        System.out.println(c);
       // it.next()
    }
}
